package com.hhsjdesign.dynamicui.core.widgetimpl.businesswidget

import android.content.Context
import android.view.View
import android.widget.FrameLayout
import android.widget.ListView
import com.hhsjdesign.dynamicui.annoprocess.AWidgetType
import com.hhsjdesign.dynamicui.core.widgetimpl.BusinessWidget
import com.hhsjdesign.dynamicui.core.property.ShapeProperty
import com.hhsjdesign.dynamicui.core.widgetdata.WidgetData
import com.hhsjdesign.dynamicui.core.property.WidgetSpecProperty
import com.hhsjdesign.dynamicui.core.widgetdata.WidgetTypeConst

//ListLayoutProperty
@AWidgetType(WidgetTypeConst.LIST)
class ListWidget(
    context: Context,
    data: WidgetData
) : BusinessWidget(context, data) {

    private lateinit var listView: ListView

    override fun layout(property: ShapeProperty, parentType: String) {
        if (parentType == WidgetTypeConst.LAYOUT_LINEAR_VERTICAL) {
            contentView?.layoutParams =
                FrameLayout.LayoutParams(property.width, property.height)
        }
    }

    override fun onLoadData() {
    }

    override fun createMainView(specProperty: WidgetSpecProperty): View {
        listView = ListView(context)
        return listView
    }
}